package com.heima.controller;


import com.heima.pojo.dto.NodeAddDto;
import com.heima.pojo.dto.NodeSearchDto;
import com.heima.pojo.dto.NodeUpdateDto;
import com.heima.pojo.dto.RegionDetailSearchDto;
import com.heima.pojo.vo.NodeDetailVo;
import com.heima.pojo.vo.NodeVo;
import com.heima.pojo.vo.PageResponseVo;
import com.heima.pojo.vo.RegionDetailVO;
import com.heima.service.NodeService;
import com.heima.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/vm-service/node")
public class NodeController {
    @Autowired
    private RegionService regionService;
    @Autowired
    private NodeService nodeService;

    //点位搜索 分页查询展示点位数据
    //查看区域详情
    @GetMapping("/search")
    public PageResponseVo<NodeVo> searchNode(NodeSearchDto nodeSearchDto) {
        return nodeService.searchNode(nodeSearchDto);
    }

    //新增点位
    @PostMapping
    public Boolean AddNode(@RequestBody NodeAddDto nodeAddDto) {
        return nodeService.addNode(nodeAddDto) > 0 ? true : false;
    }
    //获取点位详情

    @GetMapping("/vmList/{nodeId}")
    public List<NodeDetailVo> searchDetailNode(
            @PathVariable Long nodeId) {
        return nodeService.searchNodeDetailById(nodeId);
    }

    //修改点位信息
    @PutMapping("/{nodeId}")
    public Boolean updateNodeBynodeId(@PathVariable Long nodeId, @RequestBody NodeUpdateDto nodeUpdateDto) {
        return nodeService.updateNodeBynodeId(nodeId, nodeUpdateDto);
    }

    //删除点位
    @DeleteMapping("/{nodeId}")
    public Boolean deleteNodeBynodeId(@PathVariable Long nodeId) {
        return nodeService.deleteNodeBynodeId(nodeId);
    }
}
